﻿using System.Collections;
using System.Collections.Generic;

namespace WJP.ObjectModel
{
    /// <summary>
    /// 可附加参数的行为
    ///
    /// 可以给元数据附加一些额外的参数
    /// </summary>
    public interface IExtendable
    {
        /// <summary>
        /// 通过属性名称设置/获取某个值
        /// </summary>
        /// <param name="property"></param>
        /// <returns></returns>
        object this[string property] { get; set; }

        /// <summary>
        /// 获取指定名称的扩展属性值
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="property"></param>
        /// <param name="defaultValue"></param>
        /// <returns></returns>
        T GetPropertyOrDefault<T>(string property, T defaultValue = null) where T : class;

        /// <summary>
        /// 设置某个扩展属性为指定的值
        /// </summary>
        /// <param name="property"></param>
        /// <param name="value"></param>
        void SetExtendedProperty(string property, object value);

        /// <summary>
        /// 获取已经设置的所有的扩展属性
        /// </summary>
        /// <returns></returns>
        IEnumerable<KeyValuePair<string, object>> GetExtendedProperties();
    }
}